/*
 *  txdnet.cn tonydon
 * 
 */
package cn.txdnet.txcms.dao;

import cn.txdnet.txcms.domain.Feedback;
import cn.txdnet.txcms.dto.PageDTO;
import cn.txdnet.txcms.mapper.FeedbackMapper;
import cn.txdnet.txcms.query.FeedbackQuery;
import cn.txdnet.txweb.utils.CollectionUtil;
import java.util.List;

/**
 *
 * @author txdnet
 */
public class FeedbackDAO extends MybatisBaseDAO{
    
    /**
     * 保存反馈
     * @param fb
     * @return 
     */
    public int insertFeedback(Feedback fb){
         FeedbackMapper mapper = this.getMapper(FeedbackMapper.class);
         return mapper.insertFeedback(fb);
    }
    
    /**
     * 删除反馈信息
     * @param ida
     * @return 
     */
    public int deleteFeedback(int[] ida){
        FeedbackMapper mapper = this.getMapper(FeedbackMapper.class);
        return mapper.deleteFeedback(ida);
    }
    
    /**
     * 更新处理状态
     * @param fb
     * @return 
     */
    public int updateDealState(Feedback fb){
        FeedbackMapper mapper = this.getMapper(FeedbackMapper.class);
        return mapper.updateDealState(fb);
    }
    
    /**
     * 查询反馈信息
     * @param query
     * @return 
     */
    public PageDTO queryByFactor(FeedbackQuery query){
        FeedbackMapper mapper = this.getMapper(FeedbackMapper.class);
        query.filter();
        List list = mapper.listByFactor(query);
        if (query.getRownum().intValue() == 0 && CollectionUtil.isNotEmpty(list)) {
            query.setRownum(mapper.countByFactor(query));
        }
        return new PageDTO(list, query.getRownum());
    }
    
    /**
     * 查询反馈内容
     * @param msgid
     * @return 
     */
    public String queryMsg(int msgid){
        FeedbackMapper mapper = this.getMapper(FeedbackMapper.class);
        return mapper.queryMsg(msgid);
    }
}
